package com.wei.dubbo.demo.basic.api.provider;

import com.wei.dubbo.demo.basic.api.provider.service.GreetingsServiceImpl;
import com.wei.dubbo.demo.init.common.service.GreetingsService;
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ProtocolConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.ServiceConfig;
import org.apache.dubbo.config.bootstrap.DubboBootstrap;

public class BasicApiProviderApplication {
    public static void main(String[] args) {
        GreetingsService greetingsService = new GreetingsServiceImpl();

        ServiceConfig<GreetingsService> serviceConfig = new ServiceConfig<>();
        serviceConfig.setInterface(GreetingsService.class);
        serviceConfig.setRef(greetingsService);
        serviceConfig.setVersion("1.0");
        serviceConfig.setGroup("basic-api-provider-demo");

        ApplicationConfig applicationConfig = new ApplicationConfig();
        applicationConfig.setName("basic-api-provider-demo");
        applicationConfig.setQosPort(22222);
        DubboBootstrap dubboBootstrap = DubboBootstrap.getInstance()
                .application(applicationConfig)
                .registry(new RegistryConfig("zookeeper://127.0.0.1:2181"))
                .protocol(new ProtocolConfig("dubbo", -1))
                .service(serviceConfig);

        dubboBootstrap.start()
                .await();
    }
}
